# -*- coding: utf-8 -*-
# @Time : 2024/3/18 23:23
# @Author : TH
# Description:读取配置文件信息
import configparser
import os

# 获取当前目录
BASE_DIR = os.path.dirname(os.path.abspath(__file__))


class ReadConfig:
    def __init__(self):
        self.config = configparser.ConfigParser()

    def read_ini(self, section, option):
        with open(os.path.join(BASE_DIR, 'config.ini'), encoding='utf-8') as fp:
            self.config.read_file(fp)
        return self.config.get(section, option)


def get_read_obj():
    return ReadConfig()


if __name__ == '__main__':
    read = ReadConfig()
    print(read.read_ini("EXCEL", "CASE_ID"))
    print(read.read_ini("HTTP", "protocol"))
    print(read.read_ini("HTTP", "ip"))
    print(read.read_ini("HTTP", "port"))
